package moreHealthControl;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.HashMap;

//Gets all the Information selected and entered on the form and Display result on the console.
public class StudentFormOkActionListener implements ActionListener 
{
	//ATTRIBUTES ======================================
	
	//Store Key-Value Pair for every Component on the Form. 
	private HashMap<String, Object> labelValuePairx_;

	
	//CONSTRUCTORS ======================================
	//INTENT: Stores all the Key-Value Pair where the Key represents the Component Type 
	//		  and the value represents the Data.
	//PRE-CONDITION : 
		//1. The key cannot be null.
		//2. Hash-Map object [labelValuePairx_] cannot be null. 
	//POST-CONDITION: 
		//1. Associates this component and the date with respect to Key-Value pairs. 
	public StudentFormOkActionListener (HashMap<String, Object> labelValuePair){
		this.labelValuePairx_ = labelValuePair;
	}
	
	
	//INTENT: Stores the Student Info entered in the form.  
	//PRE-CONDITION : 
		//1. Enter Button should be pressed for this Event to get fired.
		//2. The texField should not be blank or null. 
		//3. The Age, Weight and Height text field needs to be int's.
		//4. Age cannot be more than 99. 
		//5. 20<=Weight<=400
		//6. 1<=Height<=7
	//POST-CONDITION: 
		//1. Adds to a Hash-map with a key[labelName] and values [Entered data].
		//2. 
	public void actionPerformed (ActionEvent e){	
	processFormRequest(e);
	}

	
	//INTENT: Gets the Information entered by the Student and execute operation defined in the StudentJourneyProcessor.
	//		  Currently the operation are: 1. Calculate Student Seriousness Factor. 2. Draw Student Journey map
	//PRE-CONDITION : 
		//1. The key-value cannot be null.
	//POST-CONDITION: 
		//1. Creates a Student Object which is used to Calculate the Seriousness Factor 
		//	 base on the data entered by the Student.
		//2. If no data was entered then default values are assumed. 
		//3. Get the Console input for the Student Journey information and display it on the Campus Map.
	public void processFormRequest(ActionEvent e)
	{	
		//Set the the Student Information entered in the form for processing. 
		StudentJourneyProcessor sjp = new StudentJourneyProcessor(labelValuePairx_);
		
		//Calculate Seriousness factor.
		sjp.configureStudentObject();
		
		//Get Student journey info and display on the map.
		sjp.getStudentJourneyCals();
}
		
}
